{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Uncomment to Start Tensorboard\n",
    "Let's start Tensorboard and point to the tensorboard logs that we downloaded from S3 directly.\n",
    "\n",
    "Note:  If you pointed Tensorboard to S3 directly, you must prepend this command with `S3_REGION=[your-region]`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "outputs_dir = './outputs'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!aws s3 cp --recursive s3://$bucket/$training_job_name/debug-output/events/ $outputs_dir/events/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!ls -al $outputs_dir/events"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#!S3_REGION=us-east-1 tensorboard --port 6006 --logdir s3://$bucket/$training_job_name/debug-output/events/  # <== MAKE SURE YOU INCLUDE THE TRAILING `/`\n",
    "!tensorboard --port 6006 --logdir $outputs_dir/events/ # <== MAKE SURE YOU INCLUDE THE TRAILING `/`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "While Tensorboard is running locally on your SageMaker Notebook instance, it is reading the training logs from Amazon S3.\n",
    "\n",
    "Navigate to https://workshop.notebook.[your-region].sagemaker.aws/proxy/6006/  <== MAKE SURE YOU INCLUDE THE TRAILING SLASH\n",
    "\n",
    "_Note:  Make sure you copy the trailing `/` in the link above.  If you see no data, you are likely not using the correct S3 bucket above._\n",
    "\n",
    "![Tensorboard](img/tensorboard.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Stop Tensorboard\n",
    "Once you are done, hit `Kernel => Stop` to stop the running `Tensorboard` process in this notebook."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "conda_python3",
   "language": "python",
   "name": "conda_python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
